﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuanLyDoiXe.Lop_du_lieu;

namespace QuanLyDoiXe.lop_doi_tuong
{
    class khachhang
    {
        string MKH,TenKH,LoaiKH;
        int SDT;
        public khachhang(){}
        public khachhang(string MKH,string TenKH,string LoaiKH,int SDT)
        {
            this.MKH = MKH;
            this.TenKH = TenKH;
            this.LoaiKH = LoaiKH;
            this.SDT = SDT;
        }
        #region Các phương thức hoạt động
        public bool taomoi()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("insert khachhang values ('" + MKH + "',N'" + TenKH + "','" + SDT + "','" + LoaiKH + "')") == 1)
            {
               lop_ket_noi.huyketnoi();
               return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool capnhat()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("update khachhang set TenKH=N'" + TenKH + "',SDT='" + SDT + "',LoaiKH=N'" + LoaiKH + "' where MKH='" + MKH + "'") == 1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool xoa()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("delete from khachhang where MKH='" + MKH + "'") == 1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        #endregion
    }
}
